package com.lyq.mr.wc;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class WordcountMapper extends Mapper<LongWritable,Text,Text,LongWritable> {

    Text t = new Text();
    LongWritable l =new LongWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] split = value.toString().split(" ");

        for (String s : split) {
            t.set(s);
            l.set(1);
            context.write(t,l);
        }
    }
}
